package mc

import (
	"gitee.com/dreamwood/ez-go/db/mgo"
)

const (
	CheckEventNew          = "mes.CheckNew"
	CheckEventBeforeCreate = "mes.CheckBeforeCreate"
	CheckEventBeforeUpdate = "mes.CheckBeforeUpdate"
	CheckEventBeforeSave   = "mes.CheckBeforeCreate mes.CheckBeforeUpdate"
	CheckEventAfterCreate  = "mes.CheckAfterCreate"
	CheckEventAfterUpdate  = "mes.CheckAfterUpdate"
	CheckEventAfterSave    = "mes.CheckAfterCreate mes.CheckAfterUpdate"
	CheckEventDelete       = "mes.CheckDelete"

	CheckAccessControlEvent = "mes.CheckAccessControl"
)

func GetCheckConfig() *mgo.DocConfig {
	return Check_Config
}

var Check_Config *mgo.DocConfig

func init() {
	Check_Config = NewCheckConfig()
}

func NewCheckConfig() *mgo.DocConfig {
	return &mgo.DocConfig{
		ContainerKey: "mes.Check",
		Fields: []string{
			"plan", "sn", "flow", "process", "num", "numX", "numH", "numF", "numSum", "emp", "results",
		},
		RelationFields: []string{
			"flow", "process", "emp", "results",
		},
		RelationConfigs: map[string]*mgo.DocRelation{

			"flow": {
				Config:     GetFlowConfig,
				DocName:    "Flow",
				JoinType:   "O",
				KeyInside:  "flowId",
				KeyOutSide: "id",
			},

			"process": {
				Config:     GetCheckProcessConfig,
				DocName:    "CheckProcess",
				JoinType:   "O",
				KeyInside:  "processId",
				KeyOutSide: "id",
			},

			"emp": {
				Config:     GetEmpConfig,
				DocName:    "Emp",
				JoinType:   "O",
				KeyInside:  "empId",
				KeyOutSide: "id",
			},

			"results": {
				Config:     GetCheckResultConfig,
				DocName:    "CheckResult",
				JoinType:   "M",
				KeyInside:  "id",
				KeyOutSide: "resultsIds",
			},
		},
		FieldFilter: map[string]*mgo.DocFieldFilter{
			"default": {
				Select: []string{},
				Omit:   []string{},
			},
		},
	}
}
